using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Globals;
using Presentation.Contracts;
using Presentation;

namespace ProjektZespolowy
{
    /// <summary>
    /// Password Reminder.
    /// </summary>
    public partial class PasswordReminder : Page, IPasswordReminderView
    {
        #region Members

        /// <summary>
        /// Presenter.
        /// </summary>
        private PasswordReminderPresenter presenter;

        #endregion Members

        #region Override Methods

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            presenter = new PasswordReminderPresenter(this);
        }

        #endregion Override Methods

        #region Private Methods

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //only not logged users can add account
            if (Session[ContentNamesGlobals.SessionWithUserId] != null)
            {
                Response.Redirect("~/Default.aspx");
            }
        }

        /// <summary>
        /// Handles the Click event of the btnRemind control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnRemind_Click(object sender, EventArgs e)
        {
            presenter.RemindPassword();
        }

        #endregion Private Methods

        #region IPasswordReminderView Members

        /// <summary>
        /// Gets or sets the login_.
        /// </summary>
        /// <value>The login_.</value>
        public string Login_
        {
            get
            {
                return txtLogin.Text;
            }
            set
            {
                txtLogin.Text = value;
            }
        }

        /// <summary>
        /// Sets the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void SetMessage(string message)
        {
            lblError.Text = message;
        }

        #endregion IPasswordReminderView Members
    }
}
